package com.rpa.secure.servicerpasecure.common.handler;


import com.rpa.secure.servicerpasecure.common.exception.RpaRegisterException;
import com.rpa.secure.servicerpasecure.common.exception.TaskException;
import com.rpa.secure.servicerpasecure.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器，控制业务异常
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    /**
     * 输出task错误
     */
    @ExceptionHandler
    public void exceptionHandler(TaskException taskException){
        log.info("错误信息是："+taskException);
//        return Result.error(baseException.getMessage());
    }
    /**
     * 返回业务异常
     */
    @ExceptionHandler
    public Result<Object> serviceExceptionHandler(RpaRegisterException rpaRegisterException) {
        log.info("错误信息是：" + rpaRegisterException);
        return Result.error(rpaRegisterException.getMessage());
    }
}
